#include <stdio.h>
#include <math.h>

#define YES 1
#define NO 0
#define FAILURE -1

typedef float ElemSet;
//***********¸´ÊýÀàÐÍ--Ë³Ðò´æ´¢*/复数类型--顺序存储*************8
typedef struct{
	ElemSet a;
	ElemSet b;
}Paural;

typedef int status;

status InitPaural(Paural *A,float v1,float v2){
	A->a=v1;
	A->b=v2;
	return OK;
}

ElemSet GetRealPart(Paural *A){
	return A->a;
}

ElemSet GetImagPart(Paural *A){
	return A->b;
}

int  FillImagPart(Paural *res,ElemSet v){
	res->a=v;
	return OK;
}

int  FillRealPart(Paural *res,ElemSet v){
	res->b=v;
	return OK;
}

int Addition(Paural* A,Paural *B,Paural *Res){

	FillRealPart(Res,GetRealPart(A)+GetRealPart(B));
	FillImagPart(Res,GetImagPart(A)+GetImagPart(B));
	return YES;
}

int Subtraction(Paural *A,Paural *B,Paural *Res){

	FillRealPart(Res,GetRealPart(A)-GetRealPart(B));
	FillImagPart(Res,GetImagPart(A)-GetImagPart(B));
	return YES;
}

int Multiplication(Paural *A,Paural *B,Paural *Res){
	
	FillRealPart(Res,GetRealPart(A)*GetRealPart(B)-GetImagPart(A)*GetImagPart(B));
	FillImagPart(Res,GetRealPart(A)*GetImagPart(B)+GetRealPart(B)*GetImagPart(A));
	return YES;
}

int Devision(Paural *A,Paural *B,Paural *Res){
	
	FillRealPart(Res,GetRealPart(A)*GetRealPart(B)+GetImagPart(A)*GetImagPart(B));
	FillImagPart(Res,GetRealPart(B)*GetImagPart(A)+GetRealPart(A)*GetImagPart(B));
	return YES;
}

float OneLength(Paural *A){	
	ElemSet len=GetRealPart(A)*GetRealPart(A)+GetImagPart(A)*GetImagPart(A);
	return sqrt(len);
}

